#include "StdAfx.h"
#include "Tree.h"


Tree::Tree(int treeNbr, Ogre::SceneManager* mSceneMgr, Ogre::SceneNode* forestNode, Ogre::Vector3 pos)
{
	this->position = pos;

	//std::cout << "New tree position: X=" << pos.x << " Y=" << pos.y << " Z=" << pos.z << std::endl; 

	// Creation du nom de noeud
	std::ostringstream	oss_node;
	std::string			tree_node;

	oss_node << "TreeNode_" << treeNbr;
	tree_node = oss_node.str();

	// Creation du nom de l'entite
	std::ostringstream	oss_entity;
	std::string			tree_name;

	oss_entity << "TreeName_" << treeNbr;
	tree_name = oss_entity.str();

	// Creation du noeud et de l'entite
	Ogre::SceneNode		*treeNode = forestNode->createChildSceneNode(tree_node, pos);
	Ogre::Entity		*treeEntity = mSceneMgr->createEntity(tree_name, "Tree.mesh");
	treeEntity->setMaterialName("Tree");

	// On scale le noeud pour le grandir
	treeNode->scale(9, 9, 9);

	// On attache l'entite au noeud
	treeNode->attachObject(treeEntity);
}


Tree::~Tree(void)
{
}
